

function User(name){
    this.name = name
}
// 1.要把方法放在原型对象上面，实现共享，避免内存开销
// 2.如果使用User.prototype = {}方式，要补回 constructor:User
User.prototype = {
    constructor:User,
    show(){
        console.log('show',this.name+'...')
    },
    get(){
        console.log('get...')
    }
}

const u1 = new User('u1')
const u2 = new User('u2')
console.log(User.prototype.constructor === User) // true

u1.show()
u2.show()
console.log(u1.show === u2.show) // true
